<?php
function __autoload($class){
	require_once '../'.$class.'.php';
}

$dbconnect = new DBconnect();

function formToUpdateTeamInfo($teamname)
{
	echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>
	<table>
		<tr><td>Team Name</td><td><input type='text' name='teaminfo' value='$teamname'></td></tr>
		<tr><td></td><td><input type='submit' name='updateinfo' value='Update Info'></td></tr>
	</table>
</form>";
}
require_once 'adminHeader.php';
?>
	<script type="text/javascript">
		function confirmEditTeam(){
			$confirm = $confirm = confirm("Are you sure want to edit " + document.getElementById("editteam").value+"?");
			return $confirm;
		}
	</script>
	<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post' onsubmit='confirmEditTeam()'>
		<table>
			<th>Edit Team</th>
			<tr>
				<td>Select Team</td>
				<td><select name='editteam' id='editteam'>
				<?php 
				$dbconnect->selectAllRealTeams();
				?>	
				</select></td>
			</tr>
			<tr>
				<td></td>
				<td><input type='submit' name='submit' value='Edit Team'></td>
			</tr>
		</table>
	</form>
	<?php 
		if(isset($_POST['submit'])){
			formToUpdateTeamInfo($_POST['editteam']);
			if(isset($_POST['updateinfo'])){
				
			}
			//echo $_POST['editteam']." is successfully updated in database!";
		}
		require_once 'adminFooter.php';
	?>
